import React, { Component } from 'react'

class NavBar extends Component {
    render() {
        return (
            <div style={{ background: 'red' }}>
                <button onClick={()=>{ this.props.event()
                console.log('儿子')
                }}>++</button>
                <span>navbar</span>
            </div>
        )
    }
}

class SiderBar extends Component {
    render() {
        return (
            <div style={{ background: 'yellow' }}>
                <ul>
                    <li>11</li>
                    <li>11</li>
                    <li>11</li>
                    <li>11</li>
                </ul>
            </div>
        )
    }
}

export default class App extends Component {
    state={
        isshow: false
    }
    handleClick=() => {
        console.log("888")
    }
    render() {
        return (
            <div>
                <NavBar event={this.handleClick}/>
                {/* <button onClick={()=>{this.setState({isshow: !this.state.isshow});}}>click</button> */}
                
                {this.state.isshow&&<SiderBar/>}
            </div>
        )
    }
}
/* 父传子 */
